/* * Copyright 2013 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.dashclock.exampleextension; import com.google.android.apps.dashclock.api.DashClockExtension; import com.google.android.apps.dashclock.api.ExtensionData; import android.content.Intent; import android.content.SharedPreferences; import android.net.Uri; import android.preference.PreferenceManager; public class ExampleExtension extends DashClockExtension { private static final String TAG = "ExampleExtension"; public static final String PREF_NAME = "pref_name"; @Override protected void onUpdateData(int reason) { // Get preference value. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); String name = sp.getString(PREF_NAME, getString(R.string.pref_name_default)); // Publish the extension data update. publishUpdate(new ExtensionData() .visible(true) .icon(R.drawable.ic_extension_example) .status("Hello") .expandedTitle("Hello, " + name + "!") .expandedBody("Thanks for checking out this example extension for DashClock.") .clickIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com")))); } }